package com.legrand.www.module.worker.service.impl;

import com.legrand.www.module.worker.entity.Teacher;
import com.legrand.www.module.worker.mapper.TeacherMapper;
import com.legrand.www.module.worker.service.TeacherService;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TeacherServiceImpl extends ServiceImpl<TeacherMapper, Teacher> implements TeacherService {
       @Autowired
       private TeacherMapper teacherMapper;

       @Override
       public Teacher getTeacher() {
              /*使用mybatis-plus分页*/
              EntityWrapper wrapper = new EntityWrapper();
              wrapper.where("id>{0}", 0);
              /*从第一条记录开始   不包括第一条   最多返回三条记录*/
              RowBounds rowBounds = new RowBounds(1, 3);
              List list = teacherMapper.selectPage(rowBounds, wrapper);

               /*使用自定义分页 当前页 每页多少条*/
              Page page = new Page(1, 3);
              List list2 = teacherMapper.getList(page);
              Teacher teacher = teacherMapper.selectById(1L);
              return teacher;
       }
}
